package until

import "time"

//获取上个月的一号和最后一天
func FirstAndLast(times time.Time) map[string]string {
	m := make(map[string]string, 2)
	date, month, _ := times.Date()
	first := time.Date(date, month, 1, 0, 0, 0, 0, time.Local).AddDate(0, -1, 0).Format("2006-01-02")
	last := time.Date(date, month, 31, 0, 0, 0, 0, time.Local).AddDate(0, -1, 0).Format("2006-01-02")
	m["first_day"] = first + " 00:00:00"
	m["last_day"] = last + " 23:59:59"
	return m
}

//获取当月的一号到当前的时间
func ThisMonthFirstToNow(times time.Time) map[string]string {
	m := make(map[string]string, 2)
	date, month, _ := times.Date()
	first := time.Date(date, month, 1, 0, 0, 0, 0, time.Local).Format("2006-01-02")
	last := times.Format("2006-01-02")
	m["first_day"] = first + " 00:00:00"
	m["last_day"] = last + " 23:59:59"
	return m
}

//获取昨天的开始和结束时间
func YesterdayStartAndEnd(ti time.Time) map[string]string {
	m := make(map[string]string, 2)
	start := ti.AddDate(0, 0, -1).Format("2006-01-02")
	end := ti.AddDate(0, 0, -1).Format("2006-01-02")
	m["start"] = start + " 00:00:00"
	m["end"] = end + " 23:59:59"
	return m
}
